package com.xjgzinfo.usdp.service.impl;

import com.xjgzinfo.usdp.domain.BladeVisualDb;
import com.xjgzinfo.usdp.repository.BladeVisualDbRepository;
import com.xjgzinfo.usdp.service.BladeVisualDbService;
import com.xjgzinfo.usdp.service.dto.BladeVisualDbDTO;
import com.xjgzinfo.usdp.service.mapper.BladeVisualDbMapper;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.Optional;

/**
 * Service Implementation for managing {@link BladeVisualDb}.
 */
@Service
@Transactional
public class BladeVisualDbServiceImpl implements BladeVisualDbService {

    private final Logger log = LoggerFactory.getLogger(BladeVisualDbServiceImpl.class);

    private final BladeVisualDbRepository bladeVisualDbRepository;

    private final BladeVisualDbMapper bladeVisualDbMapper;

    public BladeVisualDbServiceImpl(BladeVisualDbRepository bladeVisualDbRepository, BladeVisualDbMapper bladeVisualDbMapper) {
        this.bladeVisualDbRepository = bladeVisualDbRepository;
        this.bladeVisualDbMapper = bladeVisualDbMapper;
    }

    @Override
    public BladeVisualDbDTO save(BladeVisualDbDTO bladeVisualDbDTO) {
        log.debug("Request to save BladeVisualDb : {}", bladeVisualDbDTO);
        BladeVisualDb bladeVisualDb = bladeVisualDbMapper.toEntity(bladeVisualDbDTO);
        bladeVisualDb = bladeVisualDbRepository.save(bladeVisualDb);
        return bladeVisualDbMapper.toDto(bladeVisualDb);
    }

    @Override
    @Transactional(readOnly = true)
    public Page<BladeVisualDbDTO> findAll(Pageable pageable) {
        log.debug("Request to get all BladeVisualDbs");
        return bladeVisualDbRepository.findAll(pageable)
                .map(bladeVisualDbMapper::toDto);
    }


    @Override
    @Transactional(readOnly = true)
    public Optional<BladeVisualDbDTO> findOne(Long id) {
        log.debug("Request to get BladeVisualDb : {}", id);
        return bladeVisualDbRepository.findById(id)
                .map(bladeVisualDbMapper::toDto);
    }

    @Override
    public void delete(Long id) {
        log.debug("Request to delete BladeVisualDb : {}", id);
        bladeVisualDbRepository.deleteById(id);
    }
}
